// 3ds max effect file
// Simple vertex color - work with the Vertex Paint tool.  The max effect parser
// allows you to define any arbitary map channel to be passed in via a texcoord.
// In this case we are interested in Vertex Color, Illumination and Alpha which 
// are stored in 0,-1,-2 respectively.



// light direction (view space)

// transformations
float4x4 World      : 		WORLD;
float4x4 View       : 		VIEW;
float4x4 Projection : 		PROJECTION;
float4x4 WorldViewProj : 	WORLDVIEWPROJ;
float4x4 WorldView : 		WORLDVIEW;


int texcoord0 : Texcoord
<
    int Texcoord = 0;
    int MapChannel = 0;
>;

int texcoord1 : Texcoord
<
    int Texcoord = 1;
    int MapChannel = 1;
>;

int texcoord2 : Texcoord
<
    int Texcoord = 2;
    int MapChannel = 2;
>;

struct AppData
{
    float3 Pos      : POSITION; 
    float3 Norm     : NORMAL;
    float3 Tex0     : TEXCOORD0;
    float3 Tex1     : TEXCOORD1;
    float3 Tex2     : TEXCOORD2;
};

struct VS_OUTPUT
{
    float4 Pos      : POSITION;
    float4 Color    : TEXCOORD0;
};

VS_OUTPUT VS(
    AppData IN
)
{
    VS_OUTPUT Out = (VS_OUTPUT)0;
    
    Out.Pos = mul( float4(IN.Pos,1), WorldViewProj );    // position (projected)
    
    Out.Color.rgb = IN.Tex2.xyz * float3( 1,-1, 1);
    Out.Color.a = 1;
    
    return Out;
    
}

float4 PS(
    VS_OUTPUT IN
) : COLOR0
{
    float4 OUT = IN.Color;
    
    return OUT;
    
}

technique VertexColorOnly
{
    pass P0
    {
        ZEnable             = true;
        ZWriteEnable        = true;
        //AlphaBlendEnable    = TRUE;
        //SrcBlend            = SRCALPHA;
        //DestBlend           = InvSrcAlpha;  
        //CullMode            = None;
        
        // shaders
        VertexShader = compile vs_2_0 VS();
        PixelShader = compile ps_2_0 PS();
    }
}